﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace Base
{
    /// <summary>
    /// 方法基类
    /// </summary>
    public class ICommandBase : ICommand
    {
        public Action<object> ExecuteAction { get; set; }
        public Func<object,bool > CanExecuteFunc { get; set; }
        public event EventHandler? CanExecuteChanged;


        public bool CanExecute(object? parameter)
        {
            return this.CanExecuteFunc?.Invoke(parameter) == false;
        }

        public void Execute(object? parameter)
        {
            this.ExecuteAction?.Invoke  (parameter);
        }
    }
}
